<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/style.css">
    <link rel="icon" href="__PUBLIC__/static/image/code.png">
</head>
<body class="body">
<div class="tab-top layui-box layui-col-md-offset1">


<div class="search">
  <form class="layui-form" action="">
        <div class="layui-input-inline">
        <select name="search" lay-verify="required" class="search-name" lay-search="">
          <option value="user" {$search=='user' ? 'selected=""' : ''}>用户名</option>
          <option value="ip" {$search=='ip' ? 'selected=""' : ''}>IP</option>
        </select>
      </div>
  <div class="layui-inline">
    <input class="layui-input layui-input-sm" name="val" placeholder="请输入用户名" id="search-elm" autocomplete="off" value="{$val}">
  </div>
  <button class="layui-btn site-demo-active layui-btn-sm search-btn" data-type="reload">搜索</button>
</form>
</div>
</div>

<div class="system-table-1 layui-clear" style="padding-top:10px;">

<table class="layui-table" lay-filter="parse-table-demo" lay-data="{height:'full-120',url:'{:url('admin/LoginLog/ajaxlist',\Request::param())}', page:true, id:'test',limit:'{:config('webconfig.page')}'}">
  <thead>
    <tr>
     <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
      <th lay-data="{field:'id', width:50, sort: true}">ID</th>
      <th lay-data="{field:'user', width:100}">用户</th>
      <th lay-data="{field:'nickname', width:100}">用户简称</th>
      <th lay-data="{field:'ip', width:150}">ip</th>
      <th lay-data="{field:'update_time', width:180}">时间</th>
      <th lay-data="{field:'address', minwidth:120}">所在地区</th>
    </tr> 
  </thead>
</table>

</div>
<button class="layui-btn getCheckData layui-btn-sm">删去选择中数据</button>
<!-- 通用-970*90 -->
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__ADMIN__/js/comm.js" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['form', 'table'], function() {
    var $ = layui.jquery,
        form = layui.form,
        table = layui.table;
    // you code ...
  $('.getCheckData').on('click', function(){
  	var list = '';
      var checkStatus = table.checkStatus('test')
      ,data = checkStatus.data;
      console.log(data.length);
      for (var i = data.length - 1; i >= 0; i--) {
      	list += data[i].id + ',';
      }
      // 去除最后一位逗号
      list = list.substr(0, (list.length - 1));
	  $.post("{:url('admin/LoginLog/deleteAll')}", {'ids': list}, function(data) {
			if (data.code ==1) {
				layer.msg(data.msg, {time: 1000}, function() {
                      //执行重载
                    table.reload('test', {page: {curr: 1 }});
                });
			}else if(data != ""){
        layer.msg(data.msg);
      }
	   });
  });



});
</script>
</body>
</html>